package org.nicocube.airain.gwt.client.ui.item;

import java.util.LinkedList;
import java.util.List;

import com.google.gwt.user.client.ui.HTMLTable;
import com.google.gwt.user.client.ui.Label;

public class ItemValued implements Item {

	private static final String DaGridIdent = "daGridIdent";
	private static final String DaGridValue = "daGridValue";
	
	private String identClassName;
	private String ident;
	
	private String valueClassName;
	private List<String> values;

	public ItemValued() {
		this(DaGridIdent,DaGridValue);
	}
	
	public ItemValued(String identClassName,String valueClassName) {
		this.identClassName = identClassName;
		this.valueClassName = valueClassName;
		this.values = new LinkedList<String>();
	}
	
	public ItemValued setIdent(String ident) {
		this.ident = ident;
		return this;
	}
	
	public ItemValued addValue(String value) {
		values.add(value);
		return this;
	}
	
	public void render(int row, HTMLTable g) {
	
		Label lIdent = new Label(ident);
		lIdent.setStylePrimaryName(identClassName);
		g.setWidget(row, 0, lIdent);

		int i=1;		
		for (String value : values) {
			Label lValue = new Label(value);
			lValue.setStylePrimaryName(valueClassName);
			g.setWidget(row, i, lValue);
			i++;
		}
	}

}
